@section('meta')
    <style>
        body{background-color: #fff;}
        .modal-content{display: unset;}
        .layui-form-label {width: 100px;}
        .layui-input-block {margin-left: 138px;}
        .layui-input, .layui-textarea {width: 86%;}
        .layui-input.layui-bg-gray {line-height: 38px;}
        .layui-form-select .layui-edge {right: 16%;}
        .layui-form-select dl {min-width: 86%;}
        .new-table {margin: 20px 0;}
    </style>
@endsection
@include('Home.User.Common._meta')
<!----  新增： 所有客户  ---->
<div class="modal-content" id="addNew-content2">
    <form class="layui-form modal-client-info" action="" id="form-user" lay-filter="form-user">
        @if(Auth::user()->hasAnyRole(['admin']) || Auth::id()==$obj->assign || Auth::id()==$obj->uid || $obj->share || !$obj->display)
            <div class="modal-func-btns">
                @if(!$obj->display)
                    <a href="javascript:;" class="modal-save-btn" onclick="buy('{{route('client_buy',$obj->id)}}')" title="下载客户资料">下载客户资料</a>
                @endif
                @if(Auth::user()->hasAnyRole(['admin']) || Auth::id()==$obj->assign || Auth::id()==$obj->uid || $obj->share)
                    <a href="javascript:;" class="modal-save-btn" onclick="subForm('{{route('edit_client',$obj->id)}}')" title="保存"><i class="icon icon-save"></i></a>
                    <a href="javascript:location.replace(location.href);" class="modal-edit-btn" title="重置"><i class="icon icon-edit"></i></a>
                @endif
            </div>
            @include('Home.User.Common._msg')
        @endif
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="red">*</span>公司中文名</label>
            <div class="layui-input-block">
                @if(Auth::user()->hasAnyRole(['admin']) || Auth::id()==$obj->uid)
                    <input type="text" name="chinese_name" value="{{$obj->chinese_name}}" lay-verify="required" placeholder="若个人非猎头公司则写姓名" autocomplete="off" class="layui-input">
                @else
                    <div class="layui-input layui-bg-gray">{{$obj->chinese_name}}</div>
                @endif
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">英文名称</label>
            <div class="layui-input-block">
                @if(Auth::user()->hasAnyRole(['admin']) || Auth::id()==$obj->uid)
                    <input type="text" name="english_name" value="{{$obj->english_name}}" lay-verify="" placeholder="请输入公司英文名称" autocomplete="off" class="layui-input">
                @else
                    <div class="layui-input layui-bg-gray">{{$obj->english_name}}</div>
                @endif
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="red">*</span>公司简称</label>
            <div class="layui-input-block">
                @if(Auth::user()->hasAnyRole(['admin']) || Auth::id()==$obj->uid)
                    <input type="text" name="abbreviation_name" value="{{$obj->abbreviation_name}}" lay-verify="required" placeholder="检验同名公司" autocomplete="off" class="layui-input">
                @else
                    <div class="layui-input layui-bg-gray">{{$obj->abbreviation_name}}</div>
                @endif
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">代替名称</label>
            <div class="layui-input-block">
                @if(Auth::user()->hasAnyRole(['admin']) || Auth::id()==$obj->uid)
                    <input type="text" name="replace_name" value="{{$obj->replace_name}}" lay-verify="required" placeholder="用于对外展示，若不写则显示中文前2字符" autocomplete="off" class="layui-input">
                @else
                    <div class="layui-input layui-bg-gray">{{$obj->replace_name}}</div>
                @endif
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">公司网站地址</label>
            <div class="layui-input-block">
                @if(Auth::user()->hasAnyRole(['admin']) || Auth::id()==$obj->uid)
                    <input type="url" name="related_url" value="{{$obj->url}}" lay-verify="" placeholder="请输入公司网址" autocomplete="off" class="layui-input">
                @else
                    @if($obj->display)
                        <div class="layui-input layui-bg-gray">{{$obj->url}}</div>
                    @else
                        <div class="layui-input layui-bg-gray"><a href="javascript:;" onclick="buy('{{route('client_buy',$obj->id)}}')">********</a></div>
                    @endif
                @endif
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="red">*</span>公司联系人</label>
            <div class="layui-input-block">
                @if(Auth::user()->hasAnyRole(['admin']) || Auth::id()==$obj->uid)
                    <input type="text" name="contacts" value="{{$obj->contacts}}" lay-verify="required" placeholder="请输入公司联系人" autocomplete="off" class="layui-input">
                @else
                    @if($obj->display)
                        <div class="layui-input layui-bg-gray">{{$obj->contacts}}</div>
                    @else
                        <div class="layui-input layui-bg-gray"><a href="javascript:;" onclick="buy('{{route('client_buy',$obj->id)}}')">********</a></div>
                    @endif
                @endif
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系人职务</label>
            <div class="layui-input-block">
                @if(Auth::user()->hasAnyRole(['admin']) || Auth::id()==$obj->uid)
                    <input type="text" name="duties" value="{{$obj->duties}}" lay-verify="" placeholder="请输入联系人职务" autocomplete="off" class="layui-input">
                @else
                    @if($obj->display)
                        <div class="layui-input layui-bg-gray">{{$obj->duties}}</div>
                    @else
                        <div class="layui-input layui-bg-gray"><a href="javascript:;" onclick="buy('{{route('client_buy',$obj->id)}}')">********</a></div>
                    @endif
                @endif
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系人性别</label>
            <div class="layui-input-block">
                @if(Auth::user()->hasAnyRole(['admin']) || Auth::id()==$obj->uid)
                    <input type="radio" name="sex" value="1" title="男" @if($obj->sex == 1) checked @endif>
                    <input type="radio" name="sex" value="2" title="女" @if($obj->sex == 2) checked @endif>
                    <input type="radio" name="sex" value="3" title="不详" @if($obj->sex == 3) checked @endif>                @else
                    @if($obj->display)
                        <div class="layui-input layui-bg-gray">
                            @switch($obj->sex)
                                @case(1)
                                男
                                @break
                                @case(2)
                                女
                                @break
                                @case(3)
                                不详
                                @break
                                @default
                                不详
                            @endswitch
                        </div>
                    @else
                        <div class="layui-input layui-bg-gray"><a href="javascript:;" onclick="buy('{{route('client_buy',$obj->id)}}')">********</a></div>
                    @endif
                @endif
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="red">*</span>国家区号</label>
            <div class="layui-input-block">
                @if(Auth::user()->hasAnyRole(['admin']) || Auth::id()==$obj->uid)
                    <select name="country_code" id="country_code" lay-search>
                        <option value="0" disabled selected>请选择</option>
                        <option value="63" @if($obj->country_code == 63) selected @endif>菲律宾（+ 63）</option>
                        <option value="86" @if($obj->country_code == 86) selected @endif>中国大陆（+ 86）</option>
                        <option value="853" @if($obj->country_code == 853) selected @endif>澳门（+ 853）</option>
                        <option value="852" @if($obj->country_code == 852) selected @endif>香港（+ 852）</option>
                        <option value="886" @if($obj->country_code == 886) selected @endif>台湾（+ 886）</option>
                        <option value="60" @if($obj->country_code == 60) selected @endif>马来西亚（+ 60）</option>
                        <option value="66" @if($obj->country_code == 66) selected @endif>泰国（+ 66）</option>
                        <option value="65" @if($obj->country_code == 65) selected @endif>新加坡（+ 65）</option>
                        <option value="84" @if($obj->country_code == 84) selected @endif>越南（+ 84）</option>
                        <option value="95" @if($obj->country_code == 95) selected @endif>缅甸（+ 95）</option>
                        <option value="855" @if($obj->country_code == 855) selected @endif>柬埔寨（+ 855）</option>
                        <option value="856" @if($obj->country_code == 856) selected @endif>老挝（+ 856）</option>
                        <option value="62" @if($obj->country_code == 62) selected @endif>印度尼西亚（+ 62）</option>
                        <option value="350" @if($obj->country_code == 350) selected @endif>直布罗陀（+ 350）</option>
                        <option value="356" @if($obj->country_code == 356) selected @endif>马耳他（+ 356）</option>
                        <option value="58" @if($obj->country_code == 58) selected @endif>委内瑞拉（+ 58）</option>
                        <option value="504" @if($obj->country_code == 504) selected @endif>洪都拉斯（+ 504）</option>
                        <option value="505" @if($obj->country_code == 505) selected @endif>尼加拉瓜（+ 505）</option>
                        <option value="506" @if($obj->country_code == 506) selected @endif>哥斯达黎加（+ 506）</option>
                        <option value="61" @if($obj->country_code == 61) selected @endif>澳大利亚（+ 61）</option>
                    </select>
                @else
                    <div class="layui-input layui-bg-gray">{{$obj->country_code}}</div>
                @endif
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="red">*</span>联系人手机</label>
            <div class="layui-input-block">
                @if(Auth::user()->hasAnyRole(['admin']) || Auth::id()==$obj->uid)
                    <input type="tel" name="phone" value="{{$obj->phone}}" lay-verify="required|phone" autocomplete="off" class="layui-input">
                @else
                    @if($obj->display)
                        <div class="layui-input layui-bg-gray">{{$obj->phone}}</div>
                    @else
                        <div class="layui-input layui-bg-gray"><a href="javascript:;" onclick="buy('{{route('client_buy',$obj->id)}}')">********</a></div>
                    @endif
                @endif
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="red">*</span>公司电话</label>
            <div class="layui-input-block">
                @if(Auth::user()->hasAnyRole(['admin']) || Auth::id()==$obj->uid)
                    <input type="tel" name="company_phone" value="{{$obj->company_phone}}" lay-verify="required" autocomplete="off" class="layui-input">
                @else
                    @if($obj->display)
                        <div class="layui-input layui-bg-gray">{{$obj->company_phone}}</div>
                    @else
                        <div class="layui-input layui-bg-gray"><a href="javascript:;" onclick="buy('{{route('client_buy',$obj->id)}}')">********</a></div>
                    @endif
                @endif
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="red">*</span>Email</label>
            <div class="layui-input-block">
                @if(Auth::user()->hasAnyRole(['admin']) || Auth::id()==$obj->uid)
                    <input type="text" name="email" value="{{$obj->email}}" lay-verify="email" autocomplete="off" class="layui-input">
                @else
                    @if($obj->display)
                        <div class="layui-input layui-bg-gray">{{$obj->email}}</div>
                    @else
                        <div class="layui-input layui-bg-gray"><a href="javascript:;" onclick="buy('{{route('client_buy',$obj->id)}}')">********</a></div>
                    @endif
                @endif
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">其他相关网址</label>
            <div class="layui-input-block">
                @if(Auth::user()->hasAnyRole(['admin']) || Auth::id()==$obj->uid)
                    <input type="url" name="related_url" value="{{$obj->related_url}}" lay-verify="" placeholder="请输入其他相关网址" autocomplete="off" class="layui-input">
                @else
                    @if($obj->display)
                        <div class="layui-input layui-bg-gray">{{$obj->related_url}}</div>
                    @else
                        <div class="layui-input layui-bg-gray"><a href="javascript:;" onclick="buy('{{route('client_buy',$obj->id)}}')">********</a></div>
                    @endif
                @endif
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">公司地址</label>
            <div class="layui-input-block">
                @if(Auth::user()->hasAnyRole(['admin']) || Auth::id()==$obj->uid)
                    <input type="text" name="company_address" value="{{$obj->company_address}}" lay-verify="" placeholder="请输入公司地址" autocomplete="off" class="layui-input">
                @else
                    <div class="layui-input layui-bg-gray">{{$obj->company_address}}</div>
                @endif
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="red">*</span>所在地区</label>
            <div class="layui-input-block">
                @if(Auth::user()->hasAnyRole(['admin']) || Auth::id()==$obj->uid)
                    <input type="text" name="area" value="{{$obj->area}}" lay-verify="required" placeholder="请输入公司所在地区" autocomplete="off" class="layui-input">
                @else
                    <div class="layui-input layui-bg-gray">{{$obj->area}}</div>
                @endif
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="red">*</span>公司简介&福利</label>
            <div class="layui-input-block">
                @if(Auth::user()->hasAnyRole(['admin']) || Auth::id()==$obj->uid)
                    <textarea name="brief" placeholder="请输入内容" lay-verify="required" class="layui-textarea">{{$obj->brief}}</textarea>
                @else
                    <div class="layui-textarea layui-bg-gray"><pre>{{$obj->brief}}</pre></div>
                @endif
            </div>
        </div>
        {{--<div class="layui-form-item layui-form-text">--}}
            {{--<label class="layui-form-label">利益诉求</label>--}}
            {{--<div class="layui-input-block">--}}
                {{--@if(Auth::user()->hasAnyRole(['admin']) || Auth::id()==$obj->uid)--}}
                    {{--<textarea name="demand" placeholder="请输入内容" class="layui-textarea">{{$obj->demand}}</textarea>--}}
                {{--@else--}}
                    {{--<div class="layui-textarea layui-bg-gray"><pre>{{$obj->demand}}</pre></div>--}}
                {{--@endif--}}
            {{--</div>--}}
        {{--</div>--}}
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">创建人</label>
            <div class="layui-input-block">
                <div class="layui-input layui-bg-gray">{{$obj->user->username}}</div>
            </div>
        </div>
        @if(Auth::user()->hasAnyRole(['admin']) || Auth::id()==$obj->assign || $obj->share)
            <div class="layui-form-item">
                <label class="layui-form-label">指定任务归属于</label>
                <div class="layui-input-block">
                    <label for="shareTo">
                        <input type="radio" lay-filter="shareTo" id="shareTo1" name="shareTo" value="1" title="私有" @if($obj->shareTo == 1) checked @endif>
                    </label>
                    <label for="shareTo">
                        <input type="radio" lay-filter="shareTo" id="shareTo2" name="shareTo" value="2"  title="共享全员" @if($obj->shareTo == 2) checked @endif>
                    </label>
                    <label for="shareTo" class="no-margin">
                        <input type="radio" lay-filter="shareTo" id="shareTo3" name="shareTo" title="指派给" value="3" @if($obj->shareTo == 3) checked @endif>
                        <div class="layui-inline">
                            <div class="layui-input-inline" style="width: 160px;">
                                <select lay-filter="assign" id="assign" name="assign">
                                    <option value="0" disabled @if($obj->share || $obj->shareTo == 1 || $obj->shareTo == 2) selected @endif>请选择</option>
                                    @foreach($frame as $item)
                                        @foreach($item as $leader)
                                            <optgroup label="{{$leader->user->username}}">
                                                <option value="{{$leader->uid}}" @if($obj->assign == $leader->uid) selected @endif>{{$leader->user->username}}</option>
                                                @foreach($leader->member as $v)
                                                    <option value="{{$v->uid}}" @if($obj->assign == $v->uid) selected @endif>{{$v->user->username}}</option>
                                                @endforeach
                                            </optgroup>
                                        @endforeach
                                    @endforeach
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-mid layui-word-aux fs12">（若客户{{$customer_day}}天内未开发成功签约会自动变为共享，供其他人可再二次开发)</div>
                    </label>
                </div>
            </div>
        @endif
    </form>
</div>
@section('footer')
    @include('Home.User.Common._assign')
    <script>
        function buy(url) {
            layer.confirm("你确定购买吗？此操作不能撤销！(您当前拥有 {{Auth::user()->download}} 下载点，本次下载将消耗 1 下载点)", {icon: 3, title:'提示'},
                function(index){//确定回调
                    $.ajax({
                        type: 'get',
                        url: url,
                        dataType: 'json',
                        success: function(data){
                            if(data.code){
                                window.location.reload();
                                layer.close(index);
                            }else{
                                layer.msg(data.msg,{icon: 5,time:1000});
                            }
                        },
                        error:function() {
                            layer.msg('服务器错误!',{icon: 5,time:1000});
                        }
                    });
                },function (index) {//取消回调
                    layer.close(index);
                }
            );
        }
    </script>
@endsection
@include('Home.User.Common._footer')
@include('Home.User.Common._form')